/**
 * 
 */
package org.xelnaga.defiler.util.tree;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.xelnaga.defiler.domain.FolderModel;

/**
 * @author qijb
 *
 */
final class TreeInOrder {
	
	List<FolderModel> folderList = new ArrayList<FolderModel>();
	public void preOrderFolder(TreeNode<FolderModel> node) {
		// 如果传进来的节点不为空，则遍历，注，叶子节点的子节点为null
		if (node != null) {
			FolderModel bean = new FolderModel(node.getData().getId(), 
					node.getData().getTitle(), node.getDepth(), node.isLeaf());
			folderList.add(bean);
			for (Iterator<Map.Entry<Object, TreeNode<FolderModel>>> it = 
				node.getChildren(); it.hasNext();) {
				Entry<Object, TreeNode<FolderModel>> next = it.next();
				preOrderFolder(next.getValue());
			}
		}		
	}
	public List<FolderModel> getFolderList() {
		return folderList;
	}
}
